$(document).ready(function() {
	$('.datePicker').datepicker({
		changeMonth: true,
		changeYear: true
	});

	$("#create-button").live("click", function(event) {
		$.get('/elim/parishioners/create');
		$.post('/elim/rest/parishioners/create',
				$('form').serialize(),
				function(data){ 
			showResult(data, $('form'));
			if ($('#photo').val() == '')
				showDefaultPhoto();
			uploadPhoto(data.id);
		}
		);
	});

	$("#cancel-button").live("click", function(event) {
		if (confirm(jQuery.i18n.prop('ui.parishioners.confirm_quit')))
			listParishioners();
	});

	$("#person-fields input,textarea,select").live("change", function(event) {
		removeErrorClass(event);
		removeResultDiv();
	});

	$('#photo').live('change', function(event) {
		previewPhoto(this);
	});
});
